Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/NodeRepository.kt e85300531e124df08788c1b765d50af1bf6d516d (e8530053) Text, 5.96 KB

T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.repository

Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.StateFlow
Tff7b72import T7ee787org.meshtastic.core.model.MyNodeInfo
Tff7b72import T7ee787org.meshtastic.core.model.Node
Tff7b72import T7ee787org.meshtastic.core.model.NodeSortOption
Tff7b72import T7ee787org.meshtastic.proto.DeviceMetadata
Tff7b72import T7ee787org.meshtastic.proto.LocalStats
Tff7b72import T7ee787org.meshtastic.proto.User

T8b949e/**
* Repository interface for managing node-related data.
*
* This component provides access to the mesh's node database, local device information, and mesh-wide statistics. It
* supports reactive queries for node lists, counts, and filtered/sorted views.
*
* This interface is shared across platforms via Kotlin Multiplatform (KMP).
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooManyFunctionsTa5d6ff"Tb4b4b4)
Tff7b72interface T56d364NodeRepository Tb4b4b4{
T8b949e/** Reactive flow of hardware info about our local radio device. */
Tff7b72val Te6edf3myNodeInfoTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3MyNodeInfo?Tff7b72>

T8b949e/**
* Reactive flow of information about the locally connected node as seen by the mesh.
*
* This includes its position, telemetry, and user information as reflected in the mesh's node DB.
*/
Tff7b72val Te6edf3ourNodeInfoTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3Node?Tff7b72>

T8b949e/** The unique userId (hex string, e.g., "!1234abcd") of our local node. */
Tff7b72val Te6edf3myIdTb4b4b4: Te6edf3StateFlowTff7b72<Tffa657String?Tff7b72>

T8b949e/** Reactive flow of the latest local stats telemetry received from the radio. */
Tff7b72val Te6edf3localStatsTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3LocalStatsTff7b72>

T8b949e/** A reactive map of all known nodes in the mesh, keyed by their 32-bit node number. */
Tff7b72val Te6edf3nodeDBbyNumTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3NodeTff7b72>Tff7b72>

T8b949e/** Flow emitting the count of nodes currently considered "online" (heard from recently). */
Tff7b72val Te6edf3onlineNodeCountTb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/** Flow emitting the total number of nodes in the database. */
Tff7b72val Te6edf3totalNodeCountTb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/**
* Updates the cached local stats telemetry.
*
* @param stats The new [LocalStats].
*/
Tff7b72fun Td2a8ffupdateLocalStatsTb4b4b4(Te6edf3statsTb4b4b4: Te6edf3LocalStatsTb4b4b4)

T8b949e/**
* Returns the node number used for log queries.
*
* Maps the local node's number to a constant (e.g., 0) to distinguish it from remote logs.
*/
Tff7b72fun Td2a8ffeffectiveLogNodeIdTb4b4b4(Te6edf3nodeNumTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/**
* Returns the [Node] associated with a given [userId].
*
* @param userId The hex string identifier.
* @return The found [Node] or a fallback object.
*/
Tff7b72fun Td2a8ffgetNodeTb4b4b4(Te6edf3userIdTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3Node

T8b949e/**
* Returns the [User] info for a given [nodeNum].
*
* @param nodeNum The 32-bit node number.
* @return The associated [User] proto.
*/
Tff7b72fun Td2a8ffgetUserTb4b4b4(Te6edf3nodeNumTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3User

T8b949e/**
* Returns the [User] info for a given [userId].
*
* @param userId The hex string identifier.
* @return The associated [User] proto.
*/
Tff7b72fun Td2a8ffgetUserTb4b4b4(Te6edf3userIdTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3User

T8b949e/**
* Returns a reactive flow of nodes filtered and sorted according to the parameters.
*
* @param sort The [NodeSortOption] to apply.
* @param filter A search string for filtering by name or ID.
* @param includeUnknown Whether to include nodes with unset hardware models.
* @param onlyOnline Whether to include only nodes currently considered online.
* @param onlyDirect Whether to include only nodes heard directly (0 hops away).
*/
Tff7b72fun Td2a8ffgetNodesTb4b4b4(
Te6edf3sortTb4b4b4: Te6edf3NodeSortOption Tff7b72= Te6edf3NodeSortOptionTb4b4b4.Te6edf3LAST_HEARDTb4b4b4,
Te6edf3filterTb4b4b4: Tffa657String Tff7b72= Ta5d6ff"Ta5d6ff"Tb4b4b4,
Te6edf3includeUnknownTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72trueTb4b4b4,
Te6edf3onlyOnlineTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
Te6edf3onlyDirectTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3ListTff7b72<Te6edf3NodeTff7b72>Tff7b72>

T8b949e/** Returns all nodes that haven't been heard from since the given timestamp. */
Tff7b72suspend Tff7b72fun Td2a8ffgetNodesOlderThanTb4b4b4(Te6edf3lastHeardTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72>

T8b949e/** Returns all nodes with unknown hardware models. */
Tff7b72suspend Tff7b72fun Td2a8ffgetUnknownNodesTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72>

T8b949e/**
* Deletes all nodes from the database.
*
* @param preserveFavorites If true, nodes marked as favorite will not be deleted.
*/
Tff7b72suspend Tff7b72fun Td2a8ffclearNodeDBTb4b4b4(Te6edf3preserveFavoritesTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4)

T8b949e/** Clears the local node's connection info from the cache. */
Tff7b72suspend Tff7b72fun Td2a8ffclearMyNodeInfoTb4b4b4(Tb4b4b4)

T8b949e/**
* Deletes a specific node by its node number.
*
* @param num The node number to delete.
*/
Tff7b72suspend Tff7b72fun Td2a8ffdeleteNodeTb4b4b4(Te6edf3numTb4b4b4: Tffa657IntTb4b4b4)

T8b949e/**
* Deletes multiple nodes by their node numbers.
*
* @param nodeNums The list of node numbers to delete.
*/
Tff7b72suspend Tff7b72fun Td2a8ffdeleteNodesTb4b4b4(Te6edf3nodeNumsTb4b4b4: Te6edf3ListTff7b72<Tffa657IntTff7b72>Tb4b4b4)

T8b949e/**
* Updates the personal notes for a node.
*
* @param num The node number.
* @param notes The human-readable notes to persist.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsetNodeNotesTb4b4b4(Te6edf3numTb4b4b4: Tffa657IntTb4b4b4, Te6edf3notesTb4b4b4: Tffa657StringTb4b4b4)

T8b949e/**
* Upserts a [Node] into the persistent database.
*
* @param node The [Node] model to save.
*/
Tff7b72suspend Tff7b72fun Td2a8ffupsertTb4b4b4(Te6edf3nodeTb4b4b4: Te6edf3NodeTb4b4b4)

T8b949e/**
* Installs initial configuration data (local info and remote nodes) into the database.
*
* Used during the initial connection handshake.
*/
Tff7b72suspend Tff7b72fun Td2a8ffinstallConfigTb4b4b4(Te6edf3miTb4b4b4: Te6edf3MyNodeInfoTb4b4b4, Te6edf3nodesTb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72>Tb4b4b4)

T8b949e/**
* Persists hardware metadata for a node.
*
* @param nodeNum The node number.
* @param metadata The [DeviceMetadata] to save.
*/
Tff7b72suspend Tff7b72fun Td2a8ffinsertMetadataTb4b4b4(Te6edf3nodeNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3metadataTb4b4b4: Te6edf3DeviceMetadataTb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s